博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
csp 2017_3_3 markdown
阅读量:4216 次
发布时间:2019-05-26

本文共 2847 字,大约阅读时间需要 9 分钟。

package csp2017_3_3;import java.util.Scanner;public class Main {	public static void main(String[] args) {		Scanner in = new Scanner(System.in);		String line, preline;		line = null; preline = null;		int start, end;		String text = "";		while(in.hasNextLine()) {			line = in.nextLine();			if( line == null || line.length() == 0) {				if(preline == null)//跳过多个空行					continue;								if(preline.contains("
")) { System.out.print(preline + "\n" + "" + "\n"); } else if(preline.contains("

")) { System.out.print(preline+ "

" + "\n"); } preline = null;//输出当前模块后 需要置 continue; } //强调 @两种写法 // while((start = line.indexOf("_")) != -1){// end = line.indexOf("_",start+1);// text = line.substring(start, end+1);// line = line.replace(text,"
"+text.substring(1,text.length()-1)+"");// } //超链接// while((start = line.indexOf("[")) != -1){// end = line.indexOf("]",start+1);// text = line.substring(start+1, end);// int khstart = line.indexOf("(",end);// int khend = line.indexOf(")",khstart);// String link = line.substring(khstart+1,khend);// line = line.replace("["+text+"]"+"("+link+")","
"+text+"");//注意 href=后面没有空格// } while((start = line.indexOf("_")) != -1) { end = line.indexOf("_",start+1); String tmp = ""; tmp += "
" + line.substring(start+1,end) + ""; line = line.substring(0,start) + tmp + line.substring(end+1); } while((start = line.indexOf("["))!= -1) { end = line.indexOf("]",start+1); String tex = line.substring(start+1,end); int tStart = line.indexOf("(",end); int tEnd = line.indexOf(")",tStart); String link = line.substring(tStart+1,tEnd); line = line.substring(0,start) + "
" + tex+ "" + line.substring(tEnd+1); } int num = 0; if(line.startsWith("#")) { while(line.startsWith("#") && num <= 6) { num++; line = line.substring(1); } while(line.startsWith(" ")) { // line.replaceFirst(" ", ""); line本身没变 陷入死循环 line = line.replaceFirst(" ", ""); } preline = "
"+line + "" + "\n"; } else if(line.startsWith("*")) { line = line.replace("*", ""); while(line.startsWith(" ")) line = line.substring(1); if(preline == null) { preline = "
    "+"\n"+"
  • "+line+"
  • "; } else { preline += "\n" + "
  • " + line + "
  • "; } } else { if(preline == null) { preline = "

    " + line; } else { preline += "\n" +line; } } }//end while if(preline.contains("

    ")) { System.out.print(preline + "\n" + "

" + "\n"); } else if(preline.contains("

")) { System.out.print(preline+ "

" + "\n"); } }}

转载地址:http://hlimi.baihongyu.com/

你可能感兴趣的文章
MySQL的锁问题
查看>>
Java并发容器及其实现原理
查看>>
JVM调优方法
查看>>
MySQL的高可用
查看>>
Spring的注解驱动开发
查看>>
NoSQL数据库之Redis
查看>>
从IO-BIO-NIO-AIO-到Netty
查看>>
手写一个简易跳表(Java版)
查看>>
深入理解Redis
查看>>
SpringMVC实战与源码分析
查看>>
计算机操作系统--文件管理
查看>>
设计模式之行为型模式
查看>>
设计模式之结构型模式
查看>>
Java的反射机制
查看>>
HashMap源码分析
查看>>
LinkedList源码分析
查看>>
这个不错!
查看>>
好久不写Qsort了,今天居然编译器不认识,日了!
查看>>
好久不做ACM 做起来手生的很。。
查看>>
对CODEFISH的意见
查看>>